<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="news.dao.impl.*" %>
<%@ page import="org.news.dao.*" %>
<%@ page import="news.entity.*" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <%-- <base href="<%=basePath%>"> --%>
    
    <title>My JSP 'doShowNews.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    <!-- //对新增加的评论进行保存并重定向到showNews页面 -->
    <%
    request.setCharacterEncoding("UTF-8");
    int cnid = Integer.parseInt(request.getParameter("nid"));
    String cauthor = request.getParameter("cauthor");
    String cip = request.getParameter("cip");
    String ccontent =request.getParameter("ccontent");
     Comment comment = new Comment();
     comment.setCauthor(cauthor);
     comment.setCcontent(ccontent);
     comment.setCip(cip);
     comment.setCnid(cnid);
     NewsDaoImpl aa = new NewsDaoImpl();
     int rows = aa.addComment(comment);
     if(rows>0){
     out.println("<script type='text/javascript'>"
					+ "alert('评论成功！');"
					+ "location.href='showNews.jsp?nid="+cnid+"';</script>");
     }
     else{
     out.println("<script type='text/javascript'>"
					+ "alert('评论失败！');"
					+ "location.href='showNews.jsp?nid="+cnid+"';</script>");
     }
     
    
    
     %>
  </body>
</html>
